function initialize(x, y)
{
    var myOptions =
    {
        center : new google.maps.LatLng(x, y), // (29.5500, 34.9500)
        zoom : 15,
        mapTypeId : google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById('map'), myOptions);

    var marker1Options =
    {
        position : new google.maps.LatLng(x, y), // (29.5500,
        // 34.9500)
        map : map
    };
    var marker1 = new google.maps.Marker(marker1Options);
    marker1.setMap(map);
	
    var marker2Options =
    {
        position : new google.maps.LatLng(29.7000, 35.10000), // (29.5500,
        // 34.9500)
        map : map
    };
	
	
    var marker2 = new google.maps.Marker(marker2Options);
    marker2.setMap(map);

	
//    var myHtml = '<h1> Zoom Marker Data </h1>';

    /* infoWindow.setContent(myHtml);*/

		
	
    var infoWindowOptions =
    {
        content : 'Dror In Eilat :)' // TODO get from DB
    };
    
    var infoWindow = new google.maps.InfoWindow(infoWindowOptions);
    google.maps.event.addListener(marker1, 'click', function(e)
    {

        infoWindow.open(map, marker1);
    });
	
    google.maps.event.addListener(marker2, 'click', function(e)
    {

        infoWindow.open(map, marker2);
    });
	
/*
	 * var circle = new google.maps.Circle({ map: map, radius: , //1000
	 * fillColor: '#AA0000' }); circle.bindTo('center', marker, 'position');
	 */
}

function drawRadius()
{
    var map = document.getElementbyId('map');
    var circle = new google.maps.Circle(
    {
        map : map,
        radius : document.getElementbyId('radius_map').value,
        fillColor : '#AA0000'
    });
	
    circle.bindTo('center', marker1, 'position');


}
function load() {
    if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        var center = new GLatLng(32.77750, 	35.02167);
        map.setCenter(center, 15);
        geocoder = new GClientGeocoder();
        var marker = new GMarker(center, {
            draggable: true
        });  
        map.addOverlay(marker);
        document.getElementById("lat").innerHTML = center.lat().toFixed(5);
        document.getElementById("lng").innerHTML = center.lng().toFixed(5);

        GEvent.addListener(marker, "dragend", function() {
            var point = marker.getPoint();
            map.panTo(point);
            document.getElementById("lat").innerHTML = point.lat().toFixed(5);
            document.getElementById("lng").innerHTML = point.lng().toFixed(5);

        });


        GEvent.addListener(map, "moveend", function() {
            map.clearOverlays();
            var center = map.getCenter();
            var marker = new GMarker(center, {
                draggable: true
            });
            map.addOverlay(marker);
            document.getElementById("lat").innerHTML = center.lat().toFixed(5);
            document.getElementById("lng").innerHTML = center.lng().toFixed(5);


            GEvent.addListener(marker, "dragend", function() {
                var point =marker.getPoint();
                map.panTo(point);
                document.getElementById("lat").innerHTML = point.lat().toFixed(5);
                document.getElementById("lng").innerHTML = point.lng().toFixed(5);

            });
 
        });

    }
    showAddressValue("Technion, Haifa");
}

function showAddress(address) {
    var map = new GMap2(document.getElementById("map"));
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    if (geocoder) {
        geocoder.getLatLng(
            address,
            function(point) {
                if (!point) {
                    alert(address + " not found");
                } else {
                    document.getElementById("lat").innerHTML = point.lat().toFixed(5);
                    document.getElementById("lng").innerHTML = point.lng().toFixed(5);
                    map.clearOverlays();
                    map.setCenter(point, 14);
                    var marker = new GMarker(point, {
                        draggable: true
                    });  
                    map.addOverlay(marker);

                    GEvent.addListener(marker, "dragend", function() {
                        var pt = marker.getPoint();
                        map.panTo(pt);
                        document.getElementById("lat").innerHTML = pt.lat().toFixed(5);
                        document.getElementById("lng").innerHTML = pt.lng().toFixed(5);
                    });


                    GEvent.addListener(map, "moveend", function() {
                        map.clearOverlays();
                        var center = map.getCenter();
                        var marker = new GMarker(center, {
                            draggable: true
                        });
                        map.addOverlay(marker);
                        document.getElementById("lat").innerHTML = center.lat().toFixed(5);
                        document.getElementById("lng").innerHTML = center.lng().toFixed(5);

                        GEvent.addListener(marker, "dragend", function() {
                            var pt = marker.getPoint();
                            map.panTo(pt);
                            document.getElementById("lat").innerHTML = pt.lat().toFixed(5);
                            document.getElementById("lng").innerHTML = pt.lng().toFixed(5);
                        });
 
                    });

                }
            }
            );
    }
}
function showAddressValue(address) {
    var map = new GMap2(document.getElementById("map"));
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    if (geocoder) {
        geocoder.getLatLng(
            address,
            function(point) {
                if (!point) {
                    alert(address + " not found");
                } else {
                    document.getElementById("lat").value = point.lat().toFixed(5);
                    document.getElementById("lng").value = point.lng().toFixed(5);
                    map.clearOverlays();
                    map.setCenter(point, 14);
                    var marker = new GMarker(point, {
                        draggable: true
                    });  
                    map.addOverlay(marker);

                    GEvent.addListener(marker, "dragend", function() {
                        var pt = marker.getPoint();
                        map.panTo(pt);
                        document.getElementById("lat").value = pt.lat().toFixed(5);
                        document.getElementById("lng").value = pt.lng().toFixed(5);
                    });


                    GEvent.addListener(map, "moveend", function() {
                        map.clearOverlays();
                        var center = map.getCenter();
                        var marker = new GMarker(center, {
                            draggable: true
                        });
                        map.addOverlay(marker);
                        document.getElementById("lat").value = center.lat().toFixed(5);
                        document.getElementById("lng").value = center.lng().toFixed(5);

                        GEvent.addListener(marker, "dragend", function() {
                            var pt = marker.getPoint();
                            map.panTo(pt);
                            document.getElementById("lat").value = pt.lat().toFixed(5);
                            document.getElementById("lng").value = pt.lng().toFixed(5);
                        });
 
                    });

                }
            }
            );
    }
    return false;
}
/*
function KML(){

var nyLayer = new google.maps.KmlLayer('http://www.searcharoo.net/SearchKml/newyork.kml',
    {suppressInfoWindows: true});
nyLayer.setMap(map);
google.maps.event.addListener(nyLayer, 'click', function(kmlEvent) {
  var text = kmlEvent.featureData.description;
  showInDiv(text);
});

function showInDiv(text) {
  var sidediv = document.getElementById('contentWindow');
  sidediv.innerHTML = text;
}
}
*/
function KML(){
    var myLatLng = new google.maps.LatLng(41.875696, -87.624207);
    var mapOptions = {
        zoom: 11,
        center: myLatLng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    var map = new google.maps.Map(document.getElementById("map"), mapOptions);

    var ctaLayer = new google.maps.KmlLayer('http://gmaps-samples.googlecode.com/svn/trunk/ggeoxml/cta.kml');
    ctaLayer.setMap(map);

}

function  reDirectKML(){
    //for messages
//                var wnd = 
	window.open("KML/KMLmessages.html", "mywindow","status=1,toolbar=1");
                  
                  
}

 